home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_perl.idb / usr / freeware / catman / p_man / cat3 / Opcode.Z / Opcode
Encoding:
Text File  |  1998-10-28  |  19.2 KB  |  727 lines

  1.  
  2.  
  3.  
  4.      OOOOppppccccooooddddeeee((((3333))))         22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))         OOOOppppccccooooddddeeee((((3333))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.       Opcode - Disable named opcodes when compiling    perl code
  10.  
  11.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.         use    Opcode;
  13.  
  14.  
  15.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  16.       Perl code is always compiled into an internal    format before
  17.       execution.
  18.  
  19.       Evaluating perl code (e.g. via "eval"    or "do 'file'")    causes
  20.       the code to be compiled into an internal format and then,
  21.       provided there was no    error in the compilation, executed.
  22.       The internal format is based on many distinct    _o_p_c_o_d_e_s.
  23.  
  24.       By default no    opmask is in effect and    any code can be
  25.       compiled.
  26.  
  27.       The Opcode module allow you to define    an _o_p_e_r_a_t_o_r _m_a_s_k to be
  28.       in effect when perl _n_e_x_t compiles any    code.  Attempting to
  29.       compile code which contains a    masked opcode will cause the
  30.       compilation to fail with an error. The code will not be
  31.       executed.
  32.  
  33.      NNNNOOOOTTTTEEEE
  34.       The Opcode module is not usually used    directly. See the ops
  35.       pragma and Safe modules for more typical uses.
  36.  
  37.      WWWWAAAARRRRNNNNIIIINNNNGGGG
  38.       The authors make nnnnoooo wwwwaaaarrrrrrrraaaannnnttttyyyy,    implied    or otherwise, about
  39.       the suitability of this software for safety or security
  40.       purposes.
  41.  
  42.       The authors shall not    in any case be liable for special,
  43.       incidental, consequential, indirect or other similar damages
  44.       arising from the use of this software.
  45.  
  46.       Your mileage will vary. If in    any doubt ddddoooo nnnnooootttt uuuusssseeee iiiitttt.
  47.  
  48.      OOOOppppeeeerrrraaaattttoooorrrr NNNNaaaammmmeeeessss aaaannnndddd    OOOOppppeeeerrrraaaattttoooorrrr LLLLiiiissssttttssss
  49.       The canonical    list of    operator names is the contents of the
  50.       array    op_name    defined    and initialised    in file    _o_p_c_o_d_e._h of
  51.       the Perl source distribution (and installed into the perl
  52.       library).
  53.  
  54.       Each operator    has both a terse name (its opname) and a more
  55.       verbose or recognisable descriptive name. The    opdesc
  56.       function can be used to return a list    of descriptions    for a
  57.       list of operators.
  58.  
  59.       Many of the functions    and methods listed below take a    list
  60.  
  61.  
  62.  
  63.      Page 1                        (printed 10/23/98)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      OOOOppppccccooooddddeeee((((3333))))         22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))         OOOOppppccccooooddddeeee((((3333))))
  71.  
  72.  
  73.  
  74.       of operators as parameters. Most operator lists can be made
  75.       up of    several    types of element. Each element can be one of
  76.  
  77.       an operator name (opname)
  78.           Operator names are typically small lowercase words
  79.           like enterloop, leaveloop, last, next, redo etc.
  80.           Sometimes they are rather cryptic like gv2cv,    i_ncmp
  81.           and ftsvtx.
  82.  
  83.       an operator tag name (optag)
  84.           Operator tags    can be used to refer to    groups (or
  85.           sets)    of operators.  Tag names always    begin with a
  86.           colon. The Opcode module defines several optags and
  87.           the user can define others using the define_optag
  88.           function.
  89.  
  90.       a negated opname or optag
  91.           An opname or optag can be prefixed with an
  92.           exclamation mark, e.g., !mkdir.  Negating an opname
  93.           or optag means remove    the corresponding ops from the
  94.           accumulated set of ops at that point.
  95.  
  96.       an operator set (opset)
  97.           An _o_p_s_e_t as a    binary string of approximately 43
  98.           bytes    which holds a set or zero or more operators.
  99.  
  100.           The opset and    opset_to_ops functions can be used to
  101.           convert from a list of operators to an opset and
  102.           _v_i_c_e _v_e_r_s_a.
  103.  
  104.           Wherever a list of operators can be given you    can
  105.           use one or more opsets.  See also Manipulating
  106.           Opsets below.
  107.  
  108.      OOOOppppccccooooddddeeee FFFFuuuunnnnccccttttiiiioooonnnnssss
  109.       The Opcode package contains functions    for manipulating
  110.       operator names tags and sets.    All are    available for export
  111.       by the package.
  112.  
  113.       opcodes In a scalar context opcodes returns the number of
  114.           opcodes in this version of perl (around 340 for
  115.           perl5.002).
  116.  
  117.           In a list context it returns a list of all the
  118.           operator names.  (Not    yet implemented, use @names =
  119.           _o_p_s_e_t__t_o__o_p_s(full_opset).)
  120.  
  121.       opset    (OP, ...)
  122.           Returns an opset containing the listed operators.
  123.  
  124.       opset_to_ops (OPSET)
  125.           Returns a list of operator names corresponding to
  126.  
  127.  
  128.  
  129.      Page 2                        (printed 10/23/98)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      OOOOppppccccooooddddeeee((((3333))))         22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))         OOOOppppccccooooddddeeee((((3333))))
  137.  
  138.  
  139.  
  140.           those    operators in the set.
  141.  
  142.       opset_to_hex (OPSET)
  143.           Returns a string representation of an    opset. Can be
  144.           handy    for debugging.
  145.  
  146.       full_opset
  147.           Returns an opset which includes all operators.
  148.  
  149.       empty_opset
  150.           Returns an opset which contains no operators.
  151.  
  152.       invert_opset (OPSET)
  153.           Returns an opset which is the    inverse    set of the one
  154.           supplied.
  155.  
  156.       verify_opset (OPSET, ...)
  157.           Returns true if the supplied opset looks like    a
  158.           valid    opset (is the right length etc)    otherwise it
  159.           returns false. If an optional    second parameter is
  160.           true then verify_opset will croak on an invalid
  161.           opset    instead    of returning false.
  162.  
  163.           Most of the other Opcode functions call verify_opset
  164.           automatically    and will croak if given    an invalid
  165.           opset.
  166.  
  167.       define_optag (OPTAG, OPSET)
  168.           Define OPTAG as a symbolic name for OPSET. Optag
  169.           names    always start with a colon :.
  170.  
  171.           The optag name used must not be defined already
  172.           (define_optag    will croak if it is already defined).
  173.           Optag    names are global to the    perl process and optag
  174.           definitions cannot be    altered    or deleted once
  175.           defined.
  176.  
  177.           It is    strongly recommended that applications using
  178.           Opcode should    use a leading capital letter on    their
  179.           tag names since lowercase names are reserved for use
  180.           by the Opcode    module.    If using Opcode    within a
  181.           module you should prefix your    tags names with    the
  182.           name of your module to ensure    uniqueness and thus
  183.           avoid    clashes    with other modules.
  184.  
  185.       opmask_add (OPSET)
  186.           Adds the supplied opset to the current opmask. Note
  187.           that there is    currently _n_o mechanism for unmasking
  188.           ops once they    have been masked.  This    is
  189.           intentional.
  190.  
  191.  
  192.  
  193.  
  194.  
  195.      Page 3                        (printed 10/23/98)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      OOOOppppccccooooddddeeee((((3333))))         22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))         OOOOppppccccooooddddeeee((((3333))))
  203.  
  204.  
  205.  
  206.       opmask  Returns an opset corresponding to the    current
  207.           opmask.
  208.  
  209.       opdesc (OP, ...)
  210.           This takes a list of operator    names and returns the
  211.           corresponding    list of    operator descriptions.
  212.  
  213.       opdump (PAT)
  214.           Dumps    to STDOUT a two    column list of op names    and op
  215.           descriptions.     If an optional    pattern    is given then
  216.           only lines which match the (case insensitive)
  217.           pattern will be output.
  218.  
  219.           It's designed    to be used as a    handy command line
  220.           utility:
  221.  
  222.               perl -MOpcode=opdump -e opdump
  223.               perl -MOpcode=opdump -e 'opdump Eval'
  224.  
  225.  
  226.      MMMMaaaannnniiiippppuuuullllaaaattttiiiinnnngggg OOOOppppsssseeeettttssss
  227.       Opsets may be    manipulated using the perl bit vector
  228.       operators & (and), | (or), ^ (xor) and ~ (negate/invert).
  229.  
  230.       However you should never rely    on the numerical position of
  231.       any opcode within the    opset. In other    words both sides of a
  232.       bit vector operator should be    opsets returned    from Opcode
  233.       functions.
  234.  
  235.       Also,    since the number of opcodes in your current version of
  236.       perl might not be an exact multiple of eight,    there may be
  237.       unused bits in the last byte of an upset. This should    not
  238.       cause    any problems (Opcode functions ignore those extra
  239.       bits)    but it does mean that using the    ~ operator will
  240.       typically not    produce    the same 'physical' opset 'string' as
  241.       the invert_opset function.
  242.  
  243.      TTTTOOOO    DDDDOOOO ((((mmmmaaaayyyybbbbeeee))))
  244.           $bool = opset_eq($opset1,    $opset2)  true if opsets are logically eqiv
  245.  
  246.           $yes = opset_can($opset, @ops)      true if $opset has all @ops set
  247.  
  248.           @diff = opset_diff($opset1, $opset2) => ('foo', '!bar', ...)
  249.  
  250.  
  251.      PPPPrrrreeeeddddeeeeffffiiiinnnneeeedddd    OOOOppppccccooooddddeeee TTTTaaaaggggssss
  252.       :base_core
  253.  
  254.            null    stub scalar pushmark wantarray const defined undef
  255.  
  256.            rv2sv sassign
  257.  
  258.  
  259.  
  260.  
  261.      Page 4                        (printed 10/23/98)
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.      OOOOppppccccooooddddeeee((((3333))))         22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))         OOOOppppccccooooddddeeee((((3333))))
  269.  
  270.  
  271.  
  272.            rv2av aassign aelem aelemfast aslice    av2arylen
  273.  
  274.            rv2hv helem hslice each values keys exists delete
  275.  
  276.            preinc i_preinc predec i_predec postinc i_postinc postdec i_postdec
  277.            int hex oct abs pow multiply    i_multiply divide i_divide
  278.            modulo i_modulo add i_add subtract i_subtract
  279.  
  280.            left_shift right_shift bit_and bit_xor bit_or negate    i_negate
  281.            not complement
  282.  
  283.            lt i_lt gt i_gt le i_le ge i_ge eq i_eq ne i_ne ncmp    i_ncmp
  284.            slt sgt sle sge seq sne scmp
  285.  
  286.            substr vec stringify    study pos length index rindex ord chr
  287.  
  288.            ucfirst lcfirst uc lc quotemeta trans chop schop chomp schomp
  289.  
  290.            match split qr
  291.  
  292.            list    lslice splice push pop shift unshift reverse
  293.  
  294.            cond_expr flip flop andassign orassign and or xor
  295.  
  296.            warn    die lineseq nextstate unstack scope enter leave
  297.  
  298.            rv2cv anoncode prototype
  299.  
  300.            entersub leavesub return method -- XXX loops    via recursion?
  301.  
  302.            leaveeval --    needed for Safe    to operate, is safe without entereval
  303.  
  304.  
  305.       :base_mem
  306.            These memory related ops    are not    included in :base_core
  307.            because they can    easily be used to implement a resource
  308.            attack (e.g., consume all available memory).
  309.  
  310.            concat repeat join range
  311.  
  312.            anonlist anonhash
  313.  
  314.            Note that despite the existance of this optag a memory
  315.            resource    attack may still be possible using only
  316.            :base_core ops.
  317.  
  318.            Disabling these ops is a    _v_e_r_y heavy handed way to
  319.            attempt to prevent a memory resource attack. It's
  320.            probable    that a specific    memory limit mechanism will be
  321.            added to    perl in    the near future.
  322.  
  323.  
  324.  
  325.  
  326.  
  327.      Page 5                        (printed 10/23/98)
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.      OOOOppppccccooooddddeeee((((3333))))         22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))         OOOOppppccccooooddddeeee((((3333))))
  335.  
  336.  
  337.  
  338.       :base_loop
  339.            These loop ops are not included in :base_core because
  340.            they can    easily be used to implement a resource attack
  341.            (e.g., consume all available CPU    time).
  342.  
  343.            grepstart grepwhile
  344.            mapstart mapwhile
  345.            enteriter iter
  346.            enterloop leaveloop
  347.            last    next redo
  348.            goto
  349.  
  350.  
  351.       :base_io
  352.            These ops enable    _f_i_l_e_h_a_n_d_l_e (rather than    filename)
  353.            based input and output. These are safe on the
  354.            assumption that only pre-existing filehandles are
  355.            available for use.  To create new filehandles other ops
  356.            such as open would need to be enabled.
  357.  
  358.            readline rcatline getc read
  359.  
  360.            formline enterwrite leavewrite
  361.  
  362.            print sysread syswrite send recv
  363.  
  364.            eof tell seek sysseek
  365.  
  366.            readdir telldir seekdir rewinddir
  367.  
  368.  
  369.       :base_orig
  370.            These are a hotchpotch of opcodes still waiting to be
  371.            considered
  372.  
  373.            gvsv    gv gelem
  374.  
  375.            padsv padav padhv padany
  376.  
  377.            rv2gv refgen    srefgen    ref
  378.  
  379.            bless -- could be used to change ownership of objects (reblessing)
  380.  
  381.            pushre regcmaybe regcreset regcomp subst substcont
  382.  
  383.            sprintf prtf    -- can core dump
  384.  
  385.            crypt
  386.  
  387.            tie untie
  388.  
  389.  
  390.  
  391.  
  392.  
  393.      Page 6                        (printed 10/23/98)
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.      OOOOppppccccooooddddeeee((((3333))))         22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))         OOOOppppccccooooddddeeee((((3333))))
  401.  
  402.  
  403.  
  404.            dbmopen dbmclose
  405.            sselect select
  406.            pipe_op sockpair
  407.  
  408.            getppid getpgrp setpgrp getpriority setpriority localtime gmtime
  409.  
  410.            entertry leavetry --    can be used to 'hide' fatal errors
  411.  
  412.  
  413.       :base_math
  414.            These ops are not included in :base_core    because    of the
  415.            risk of them being used to generate floating point
  416.            exceptions (which would have to be caught using a
  417.            $SIG{FPE} handler).
  418.  
  419.            atan2 sin cos exp log sqrt
  420.  
  421.            These ops are not included in :base_core    because    they
  422.            have an effect beyond the scope of the compartment.
  423.  
  424.            rand    srand
  425.  
  426.  
  427.       :base_thread
  428.            These ops are related to    multi-threading.
  429.  
  430.            lock    threadsv
  431.  
  432.  
  433.       :default
  434.            A handy tag name    for a _r_e_a_s_o_n_a_b_l_e default set of    ops.
  435.            (The current ops    allowed    are unstable while development
  436.            continues. It will change.)
  437.  
  438.            :base_core :base_mem    :base_loop :base_io :base_orig :base_thread
  439.  
  440.            If safety matters to you    (and why else would you    be
  441.            using the Opcode    module?)  then you should not rely on
  442.            the definition of this, or indeed any other, optag!
  443.  
  444.       :filesys_read
  445.  
  446.            stat    lstat readlink
  447.  
  448.            ftatime ftblk ftchr ftctime ftdir fteexec fteowned fteread
  449.            ftewrite ftfile ftis    ftlink ftmtime ftpipe ftrexec ftrowned
  450.            ftrread ftsgid ftsize ftsock    ftsuid fttty ftzero ftrwrite ftsvtx
  451.  
  452.            fttext ftbinary
  453.  
  454.            fileno
  455.  
  456.  
  457.  
  458.  
  459.      Page 7                        (printed 10/23/98)
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.      OOOOppppccccooooddddeeee((((3333))))         22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))         OOOOppppccccooooddddeeee((((3333))))
  467.  
  468.  
  469.  
  470.       :sys_db
  471.  
  472.            ghbyname ghbyaddr ghostent shostent ehostent         --    hosts
  473.            gnbyname gnbyaddr gnetent snetent enetent         --    networks
  474.            gpbyname gpbynumber gprotoent sprotoent eprotoent --    protocols
  475.            gsbyname gsbyport gservent sservent eservent         --    services
  476.  
  477.            gpwnam gpwuid gpwent    spwent epwent getlogin         --    users
  478.            ggrnam ggrgid ggrent    sgrent egrent             --    groups
  479.  
  480.  
  481.       :browse
  482.            A handy tag name    for a _r_e_a_s_o_n_a_b_l_e default set of    ops
  483.            beyond the :default optag.  Like    :default (and indeed
  484.            all the other optags) its current definition is
  485.            unstable    while development continues. It    will change.
  486.  
  487.            The :browse tag represents the next step    beyond
  488.            :default. It it a superset of the :default ops and adds
  489.            :filesys_read the :sys_db.  The intent being that
  490.            scripts can access more (possibly sensitive)
  491.            information about your system but not be    able to    change
  492.            it.
  493.  
  494.            :default :filesys_read :sys_db
  495.  
  496.  
  497.       :filesys_open
  498.  
  499.            sysopen open    close
  500.            umask binmode
  501.  
  502.            open_dir closedir --    other dir ops are in :base_io
  503.  
  504.  
  505.       :filesys_write
  506.  
  507.            link    unlink rename symlink truncate
  508.  
  509.            mkdir rmdir
  510.  
  511.            utime chmod chown
  512.  
  513.            fcntl -- not    strictly filesys related, but possibly as dangerous?
  514.  
  515.  
  516.       :subprocess
  517.  
  518.            backtick system
  519.  
  520.            fork
  521.  
  522.  
  523.  
  524.  
  525.      Page 8                        (printed 10/23/98)
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.      OOOOppppccccooooddddeeee((((3333))))         22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))         OOOOppppccccooooddddeeee((((3333))))
  533.  
  534.  
  535.  
  536.            wait    waitpid
  537.  
  538.            glob    -- access to Cshell via    <`rm *`>
  539.  
  540.  
  541.       :ownprocess
  542.  
  543.            exec    exit kill
  544.  
  545.            time    tms -- could be    used for timing    attacks    (paranoid?)
  546.  
  547.  
  548.       :others
  549.            This tag    holds groups of    assorted specialist opcodes
  550.            that don't warrant having optags    defined    for them.
  551.  
  552.            SystemV Interprocess Communications:
  553.  
  554.            msgctl msgget msgrcv    msgsnd
  555.  
  556.            semctl semget semop
  557.  
  558.            shmctl shmget shmread shmwrite
  559.  
  560.  
  561.       :still_to_be_decided
  562.  
  563.            chdir
  564.            flock ioctl
  565.  
  566.            socket getpeername ssockopt
  567.            bind    connect    listen accept shutdown gsockopt    getsockname
  568.  
  569.            sleep alarm -- changes global timer state and signal    handling
  570.            sort    -- assorted problems including core dumps
  571.            tied    -- can be used to access object    implementing a tie
  572.            pack    unpack -- can be used to create/use memory pointers
  573.  
  574.            entereval --    can be used to hide code from initial compile
  575.            require dofile
  576.  
  577.            caller -- get info about calling environment    and args
  578.  
  579.            reset
  580.  
  581.            dbstate -- perl -d version of nextstate(ment) opcode
  582.  
  583.  
  584.       :dangerous
  585.            This tag    is simply a bucket for opcodes that are
  586.            unlikely    to be used via a tag name but need to be
  587.            tagged for completness and documentation.
  588.  
  589.  
  590.  
  591.      Page 9                        (printed 10/23/98)
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.      OOOOppppccccooooddddeeee((((3333))))         22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))         OOOOppppccccooooddddeeee((((3333))))
  599.  
  600.  
  601.  
  602.            syscall dump    chroot
  603.  
  604.  
  605.      SSSSEEEEEEEE AAAALLLLSSSSOOOO
  606.       _o_p_s(3) -- perl pragma    interface to Opcode module.
  607.  
  608.       _S_a_f_e(3) -- Opcode and    namespace limited execution
  609.       compartments
  610.  
  611.      AAAAUUUUTTTTHHHHOOOORRRRSSSS
  612.       Originally designed and implemented by Malcolm Beattie,
  613.       mbeattie@sable.ox.ac.uk as part of Safe version 1.
  614.  
  615.       Split    out from Safe module version 1,    named opcode tags and
  616.       other    changes    added by Tim Bunce.
  617.  
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.      Page 10                        (printed 10/23/98)
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.      OOOOppppccccooooddddeeee((((3333))))         22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))         OOOOppppccccooooddddeeee((((3333))))
  665.  
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.      Page 11                        (printed 10/23/98)
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.